package com.zmyuan.demo.netty.thrift.socket;

import com.zmyuan.demo.netty.thrift.Content;
import com.zmyuan.demo.netty.thrift.Msg;
import com.zmyuan.demo.netty.thrift.ThriftRequest;
import com.zmyuan.demo.netty.thrift.service.ThriftService;
import com.zmyuan.demo.netty.thrift.utils.ThriftUtils;

/**
 * Created by zdb on 2017/2/17.
 */
public class Media {

    public static Object execute(ThriftRequest request) throws Exception {
        String cmd = request.getCommand();
        if(cmd.equals("saveMsg")) {
            return new ThriftService().saveMsg(ThriftUtils.convertBytesToObject(request.getRequestParam(), Msg.class));
        } else if("saveContent".equals(cmd)) {
            Content content = new ThriftService().saveContent(ThriftUtils.convertBytesToObject(request.getRequestParam(), Content.class));
            return content;
        }
        return null;
    }
}
